<template>
  <div class="trade-page">
    <div class="header-box">
      <div class="nav-bar" :class="isActive=='buy'?'buy-bar':''" @click="isActive='buy'">买入BTC</div>
      <div class="nav-bar" :class="isActive=='sell'?'sell-bar':''" @click="isActive='sell'">卖出BTC</div>
    </div>
    <div class="form-box">
      <!-- <el-input placeholder="买入价格">
      <span slot="suffix">usdt</span>
      </el-input>
      <el-input placeholder="买入数量">
      <span slot="suffix">usdt</span>
      </el-input>-->

      <div class="select-input dp-center-row" @click="is_show_nav=!is_show_nav">
        <span class="hint">委托类型</span>

        <span class="target">{{entrust.name}}</span>
        <i class="iconfont icon-jiantou"></i>
        <ul class="nav-list" :style="is_show_nav?'display:block':''">
          <li
            v-for="(item,index) in entrustList"
            :key="index"
            @click="navClick(item)"
            @mouseenter="entrust_active=index"
          >
            {{item.name}}
            <div class="describe" v-if="index==entrust_active">{{item.describe}}</div>
          </li>
        </ul>
      </div>
      <div class="form-input dp-center-row">
        <span class="hint">委托类型</span>
        <input class="price" type="text" />
        <span class="end_text">≈$10,928.70</span>
      </div>
      <div class="form-input">
        <input type="text" placeholder="请输入数量(BTC)" />
      </div>
      <silder></silder>
      <div class="form-input">
        <input type="text" placeholder="请输入金额" />
      </div>
      <div class="trade-info">
        <span class="hint">
          可买 BTC:
          <span :class="isActive=='buy'?'buy-sum':'sell-sum'">0.00000000</span>
        </span>
        <span class="hint">
          USDT余额:
          <span :class="isActive=='buy'?'buy-sum':'sell-sum'">0.00</span>
        </span>
      </div>
      <button class="btn" :class="isActive=='buy'?'buy':'sell'">{{isActive=='buy'?'买入':'卖出'}}BTC</button>
    </div>
  </div>
</template>

<script>
import silder from "./module/silder";
export default {
  data() {
    return {
      isActive: "buy", //buy sell

      formData: {
        type: 1, //1限价，2，市价
        price: 0,
        count: 0
      },
      entrustList: [
        {
          id: 1,
          name: "限价委托",
          describe:
            "限价委托是指用户设置委托数量以及可接受的最高买价或最低卖价，当市场价格符合用户预期时，系统会以限价范围内的最优价格进行成交。"
        },
        {
          id: 2,
          name: "市价委托",
          describe:
            "市价委托是指用户以当前市场最优价格立即执行买入或者卖出。更多详情"
        }
      ],
      entrust: {
        id: 1,
        name: "限价委托"
      }, //委托类型
      entrust_active: 1, //当前活跃的委托类型
      is_show_nav: false
    };
  },
  components: {
    silder
  },
  methods: {
    navClick(e) {
      this.entrust = e;
    }
  }
};
</script>

<style lang="less" scoped>
.buy-bar {
  background-color: #05193d;
  border-top: solid 2px #4db872;
  color: #4db872;
  box-sizing: border-box;
}
.sell-bar {
  background-color: #05193d;
  border-top: solid 2px #ee6560;
  color: #ee6560;
  box-sizing: border-box;
  
}
.trade-page {
  width: 100%;
  background-color: #05193d;
  height: 100%;
  .header-box {
    // height: 28px;
    display: flex;
    background-color: #1b3157;
    color: hsla(0, 0%, 100%, 0.45);

    .nav-bar {
      flex: 1;
      text-align: center;
      line-height: 28px;
      cursor: pointer;
      border-top: solid 2px
    }
  }
  .form-box {
    padding: 8px;
    background: #1c283e;
    font-size: 12px;
    .select-input {
      width: 100%;
      height: 32px;
      // outline: solid 1px red;
      border-radius: 4px;
      color: hsla(0, 0%, 100%, 0.85);
      padding: 5px;
      justify-content: space-between;
      background-color: #0c1929;
      position: relative;
      cursor: pointer;
      .iconfont {
        transition: all 0.3s;
      }
      &:hover {
        outline: solid 1px #5795f1;
        .iconfont {
          transform: rotate(180deg);
        }
      }
      .hint {
        color: hsla(0, 0%, 100%, 0.45);
        width: 80px;
      }
      .target {
        display: inline-block;
        width: 140px;
      }
      // 隐藏下拉框
      .nav-list {
        position: absolute;
        top: 35px;
        left: 0px;
        // outline: solid 1px red;
        width: 100%;
        background-color: #0c1929;
        display: none;
        z-index: 10;
        li {
          padding: 0 15px;
          height: 32px;
          line-height: 32px;
          color: hsla(0, 0%, 100%, 0.65);

          &:hover {
            background-color: hsla(0, 0%, 65%, 0.45);
          }

          .describe {
            position: absolute;
            top: 0px;
            left: -254px;
            outline: solid 1px rgb(78, 78, 211);
            width: 250px;
            padding: 8px;
            background: #1b3157;
            border-radius: 4px;
            line-height: 14px;
          }
        }
      }
    }
    .form-input {
      width: 100%;
      height: 32px;
      // outline: solid 1px red;
      border-radius: 4px;
      color: hsla(0, 0%, 100%, 0.85);
      padding: 5px;
      justify-content: space-between;
      background-color: #0c1929;
      position: relative;
      margin: 6px 0;
      &:hover {
        outline: solid 1px #5795f1;
      }

      .hint {
        width: 80px;
        display: inline-block;
        color: hsla(0, 0%, 100%, 0.45);
      }
      input {
        width: 100%;
        background-color: #0c1929;
        border: none;
        color: white;
      }
      .price {
        width: 100px;
      }

      .end_text {
        color: hsla(0, 0%, 80%, 0.65);
      }
    }
    .trade-info {
      width: 100%;
      display: flex;
      justify-content: space-between;
      .hint {
        color: hsla(0, 0%, 100%, 0.45);
      }
      .buy-sum {
        color: #2ead65;
      }
      .sell-sum {
        color: #e35e5e;
      }
    }
    .btn {
      width: 100%;
      height: 30px;
      border-radius: 15px;
      border: none;
      text-align: center;
      margin: 20px 0 25px 0;
      color:white;
      font-size: 16px;
      font-weight: 600;
    }
    .buy {
      background-color: #2ead65;
    }
    .sell {
      background-color: #e35e5e;
    }
  }
}
</style>